/**
 * // Definition for a Node.
 * function Node(val,children) {
 *    this.val = val;
 *    this.children = children;
 * };
 */

/**
 * @param {Node|null} root
 * @return {number}
 */
 var maxDepth = function(root) {
    const getDepth = function(root){
      if(root === null) return 0
      let children = root.children
      let max = 0
      children.forEach((child)=>{
        let childRes = getDepth(child)
        max = max > childRes ? max : childRes
      })
      return 1+max
    }
    return getDepth(root)
};